home *** CD-ROM | disk | FTP | other *** search
- 299,327d298
- < goto clist;
- <
- < } else if (c == '?') {
- <
- < clist: /* make a completion list! */
- < switch (type) {
- < case CMP_BUFFER:
- < clist_buffer(buf, &cpos);
- < break;
- < case CMP_COMMAND:
- < clist_command(buf, &cpos);
- < break;
- < case CMP_FILENAME:
- < clist_file(buf, &cpos);
- < break;
- < }
- < update(TRUE);
- <
- < /* if it exists, reprompt the user */
- < if (prompt) {
- < buf[cpos] = 0;
- < if (type == CMP_COMMAND)
- < mlwrite("%s%s", prompt, buf);
- < else if (defval)
- < mlwrite("%s[%s]: %s", prompt, defval, buf);
- < else
- < mlwrite("%s: %s", prompt, buf);
- < }
- <
- 415,450d385
- < /* clist_command: Make a completion list based on a partial name */
- <
- < clist_command(name, cpos)
- <
- < char *name; /* command containing the current name to complete */
- < int *cpos; /* ptr to position of next character to insert */
- <
- < {
- < register NBIND *bp; /* trial command to complete */
- < register int curbind; /* index into the names[] array */
- < register int name_len; /* current length of input string */
- < register BUFFER *listbuf;/* buffer to put completion list into */
- <
- < /* get a buffer for the completion list */
- < listbuf = bfind("[Completion list]", TRUE, BFINVS);
- < if (listbuf == NULL || bclear(listbuf) == FALSE) {
- < ctrlg(FALSE, 0);
- < TTflush();
- < return;
- < }
- <
- < name_len = *cpos;
- <
- < /* first, we start at the first command and scan the list */
- < for (curbind = 0; curbind <= numfunc; curbind++) {
- <
- < /* is this a match? */
- < bp = &names[curbind];
- < if (strncmp(name, bp->n_name, name_len) == 0)
- < addline(listbuf, bp->n_name);
- < }
- <
- < wpopup(listbuf);
- < return;
- < }
- <
- 524,561d458
- < /* clist_buffer: Make a completion list based on a partial buffer name */
- <
- < clist_buffer(name, cpos)
- <
- < char *name; /* command containing the current name to complete */
- < int *cpos; /* ptr to position of next character to insert */
- <
- < {
- < register int name_len; /* current length of input string */
- < register BUFFER *listbuf;/* buffer to put completion list into */
- < register BUFFER *bp; /* trial buffer to complete */
- <
- < /* get a buffer for the completion list */
- < listbuf = bfind("[Completion list]", TRUE, BFINVS);
- < if (listbuf == NULL || bclear(listbuf) == FALSE) {
- < ctrlg(FALSE, 0);
- < TTflush();
- < return;
- < }
- <
- < /* first, we start at the first buffer and scan the list */
- < name_len = *cpos;
- < bp = bheadp;
- <
- < while (bp) {
- <
- < /* is this a match? */
- < if (strncmp(name, bp->b_bname, name_len) == 0)
- < addline(listbuf, bp->b_bname);
- <
- < /* on to the next buffer */
- < bp = bp->b_bufp;
- < }
- <
- < wpopup(listbuf);
- < return;
- < }
- <
- 637,677d533
- <
- < return;
- < }
- <
- < /* clist_file: Make a completion list based on a partial file name */
- <
- < clist_file(name, cpos)
- <
- < char *name; /* command containing the current name to complete */
- < int *cpos; /* ptr to position of next character to insert */
- <
- < {
- < register int name_len; /* current length of input string */
- < register BUFFER *listbuf;/* buffer to put completion list into */
- < register char *fname; /* trial file to complete */
- <
- < /* get a buffer for the completion list */
- < listbuf = bfind("[Completion list]", TRUE, BFINVS);
- < if (listbuf == NULL || bclear(listbuf) == FALSE) {
- < ctrlg(FALSE, 0);
- < TTflush();
- < return;
- < }
- <
- < /* first, we start at the first file and scan the list */
- < name_len = *cpos;
- < name[*cpos] = 0;
- < fname = getffile(name);
- <
- < /* first, we start at the first file and scan the list */
- < while (fname) {
- <
- < /* is this a match? */
- < if (strncmp(name, fname, name_len) == 0)
- < addline(listbuf, fname);
- <
- < /* on to the next file */
- < fname = getnfile();
- < }
- <
- < wpopup(listbuf);
-